#include "foc1.h"
#include "rtwtypes.h"
#include "mwmathutil.h"
#include "foc1_private.h"
#include "rt_logging_mmi.h"
#include "foc1_capi.h"
#include "foc1_dt.h"
extern void * CreateDiagnosticAsVoidPtr_wrapper ( const char * id , int nargs
, ... ) ; RTWExtModeInfo * gblRTWExtModeInfo = NULL ; void
raccelForceExtModeShutdown ( boolean_T extModeStartPktReceived ) { if ( !
extModeStartPktReceived ) { boolean_T stopRequested = false ;
rtExtModeWaitForStartPkt ( gblRTWExtModeInfo , 3 , & stopRequested ) ; }
rtExtModeShutdown ( 3 ) ; }
#include "slsv_diagnostic_codegen_c_api.h"
#include "slsa_sim_engine.h"
const int_T gblNumToFiles = 0 ; const int_T gblNumFrFiles = 0 ; const int_T
gblNumFrWksBlocks = 0 ;
#ifdef RSIM_WITH_SOLVER_MULTITASKING
boolean_T gbl_raccel_isMultitasking = 1 ;
#else
boolean_T gbl_raccel_isMultitasking = 0 ;
#endif
boolean_T gbl_raccel_tid01eq = 0 ; int_T gbl_raccel_NumST = 4 ; const char_T
* gbl_raccel_Version = "9.9 (R2023a) 19-Nov-2022" ; void
raccel_setup_MMIStateLog ( SimStruct * S ) {
#ifdef UseMMIDataLogging
rt_FillStateSigInfoFromMMI ( ssGetRTWLogInfo ( S ) , & ssGetErrorStatus ( S )
) ;
#else
UNUSED_PARAMETER ( S ) ;
#endif
} static DataMapInfo rt_dataMapInfo ; DataMapInfo * rt_dataMapInfoPtr = &
rt_dataMapInfo ; rtwCAPI_ModelMappingInfo * rt_modelMapInfoPtr = & (
rt_dataMapInfo . mmi ) ; const int_T gblNumRootInportBlks = 0 ; const int_T
gblNumModelInputs = 0 ; extern const char * gblInportFileName ; extern
rtInportTUtable * gblInportTUtables ; const int_T gblInportDataTypeIdx [ ] =
{ - 1 } ; const int_T gblInportDims [ ] = { - 1 } ; const int_T
gblInportComplex [ ] = { - 1 } ; const int_T gblInportInterpoFlag [ ] = { - 1
} ; const int_T gblInportContinuous [ ] = { - 1 } ; int_T enableFcnCallFlag [
] = { 1 , 1 , 1 , 1 } ; const char * raccelLoadInputsAndAperiodicHitTimes (
SimStruct * S , const char * inportFileName , int * matFileFormat ) { return
rt_RAccelReadInportsMatFile ( S , inportFileName , matFileFormat ) ; }
#include "simstruc.h"
#include "fixedpoint.h"
#include "slsa_sim_engine.h"
#include "simtarget/slSimTgtSLExecSimBridge.h"
B rtB ; DW rtDW ; static SimStruct model_S ; SimStruct * const rtS = &
model_S ; real_T look1_binlxpw ( real_T u0 , const real_T bp0 [ ] , const
real_T table [ ] , uint32_T maxIndex ) { real_T frac ; real_T yL_0d0 ;
uint32_T bpIdx ; uint32_T iLeft ; uint32_T iRght ; if ( u0 <= bp0 [ 0U ] ) {
iLeft = 0U ; frac = ( u0 - bp0 [ 0U ] ) / ( bp0 [ 1U ] - bp0 [ 0U ] ) ; }
else if ( u0 < bp0 [ maxIndex ] ) { bpIdx = maxIndex >> 1U ; iLeft = 0U ;
iRght = maxIndex ; while ( iRght - iLeft > 1U ) { if ( u0 < bp0 [ bpIdx ] ) {
iRght = bpIdx ; } else { iLeft = bpIdx ; } bpIdx = ( iRght + iLeft ) >> 1U ;
} frac = ( u0 - bp0 [ iLeft ] ) / ( bp0 [ iLeft + 1U ] - bp0 [ iLeft ] ) ; }
else { iLeft = maxIndex - 1U ; frac = ( u0 - bp0 [ maxIndex - 1U ] ) / ( bp0
[ maxIndex ] - bp0 [ maxIndex - 1U ] ) ; } yL_0d0 = table [ iLeft ] ; return
( table [ iLeft + 1U ] - yL_0d0 ) * frac + yL_0d0 ; } void MdlInitialize (
void ) { rtDW . pq0qc0q4qt = rtP . DiscreteTimeIntegrator1_IC ; rtDW .
eowmvoivfm = rtP . DiscreteTimeIntegrator_IC ; rtDW . ooiulikieu = rtP .
DiscreteTimeIntegrator_IC_gww3x4gjg5 ; { int32_T i , j ; real_T * Ds = (
real_T * ) rtDW . heo4xx0bdx . DS ; for ( i = 0 ; i < 8 ; i ++ ) { for ( j =
0 ; j < 9 ; j ++ ) Ds [ i * 9 + j ] = ( rtP . StateSpace_DS_param [ i + j * 8
] ) ; } { int_T * switch_status = ( int_T * ) rtDW . heo4xx0bdx .
SWITCH_STATUS ; int_T * gState = ( int_T * ) rtDW . heo4xx0bdx . G_STATE ;
real_T * yswitch = ( real_T * ) rtDW . heo4xx0bdx . Y_SWITCH ; int_T *
switchTypes = ( int_T * ) rtDW . heo4xx0bdx . SWITCH_TYPES ; int_T * idxOutSw
= ( int_T * ) rtDW . heo4xx0bdx . IDX_OUT_SW ; int_T * switch_status_init = (
int_T * ) rtDW . heo4xx0bdx . SWITCH_STATUS_INIT ; switch_status [ 0 ] = 0 ;
switch_status_init [ 0 ] = 0 ; gState [ 0 ] = ( int_T ) 0.0 ; yswitch [ 0 ] =
1 / 0.001 ; switchTypes [ 0 ] = ( int_T ) 7.0 ; idxOutSw [ 0 ] = ( ( int_T )
0.0 ) - 1 ; switch_status [ 1 ] = 0 ; switch_status_init [ 1 ] = 0 ; gState [
1 ] = ( int_T ) 0.0 ; yswitch [ 1 ] = 1 / 0.001 ; switchTypes [ 1 ] = ( int_T
) 7.0 ; idxOutSw [ 1 ] = ( ( int_T ) 0.0 ) - 1 ; switch_status [ 2 ] = 0 ;
switch_status_init [ 2 ] = 0 ; gState [ 2 ] = ( int_T ) 0.0 ; yswitch [ 2 ] =
1 / 0.001 ; switchTypes [ 2 ] = ( int_T ) 7.0 ; idxOutSw [ 2 ] = ( ( int_T )
0.0 ) - 1 ; switch_status [ 3 ] = 0 ; switch_status_init [ 3 ] = 0 ; gState [
3 ] = ( int_T ) 0.0 ; yswitch [ 3 ] = 1 / 0.001 ; switchTypes [ 3 ] = ( int_T
) 7.0 ; idxOutSw [ 3 ] = ( ( int_T ) 0.0 ) - 1 ; switch_status [ 4 ] = 0 ;
switch_status_init [ 4 ] = 0 ; gState [ 4 ] = ( int_T ) 0.0 ; yswitch [ 4 ] =
1 / 0.001 ; switchTypes [ 4 ] = ( int_T ) 7.0 ; idxOutSw [ 4 ] = ( ( int_T )
0.0 ) - 1 ; switch_status [ 5 ] = 0 ; switch_status_init [ 5 ] = 0 ; gState [
5 ] = ( int_T ) 0.0 ; yswitch [ 5 ] = 1 / 0.001 ; switchTypes [ 5 ] = ( int_T
) 7.0 ; idxOutSw [ 5 ] = ( ( int_T ) 0.0 ) - 1 ; } } rtDW . po5e0yb1lh = rtP
. PIDController_InitialConditionForIntegrator ; rtDW . okrwv1hpip = rtP .
DiscreteTimeIntegrator_IC_mz4wlcvrk2 ; rtDW . fqew3rv1xn = rtP .
PIDController4_InitialConditionForIntegrator ; rtDW . e1ionbamw0 = rtP .
PIDController3_InitialConditionForIntegrator ; } void MdlStart ( void ) { {
bool externalInputIsInDatasetFormat = false ; void * pISigstreamManager =
rt_GetISigstreamManager ( rtS ) ;
rtwISigstreamManagerGetInputIsInDatasetFormat ( pISigstreamManager , &
externalInputIsInDatasetFormat ) ; if ( externalInputIsInDatasetFormat ) { }
} rtDW . k0ry3y4g00 = 0U ; rtDW . igdieiwmgk = 0U ; rtDW . ptj1w5chqw = 0U ;
{ rtDW . heo4xx0bdx . DS = ( real_T * ) calloc ( 8 * 9 , sizeof ( real_T ) )
; rtDW . heo4xx0bdx . DX_COL = ( real_T * ) calloc ( 8 , sizeof ( real_T ) )
; rtDW . heo4xx0bdx . TMP2 = ( real_T * ) calloc ( 9 , sizeof ( real_T ) ) ;
rtDW . heo4xx0bdx . SWITCH_STATUS = ( int_T * ) calloc ( 6 , sizeof ( int_T )
) ; rtDW . heo4xx0bdx . SW_CHG = ( int_T * ) calloc ( 6 , sizeof ( int_T ) )
; rtDW . heo4xx0bdx . G_STATE = ( int_T * ) calloc ( 6 , sizeof ( int_T ) ) ;
rtDW . heo4xx0bdx . Y_SWITCH = ( real_T * ) calloc ( 6 , sizeof ( real_T ) )
; rtDW . heo4xx0bdx . SWITCH_TYPES = ( int_T * ) calloc ( 6 , sizeof ( int_T
) ) ; rtDW . heo4xx0bdx . IDX_OUT_SW = ( int_T * ) calloc ( 6 , sizeof (
int_T ) ) ; rtDW . heo4xx0bdx . SWITCH_STATUS_INIT = ( int_T * ) calloc ( 6 ,
sizeof ( int_T ) ) ; rtDW . heo4xx0bdx . USWLAST = ( real_T * ) calloc ( 6 ,
sizeof ( real_T ) ) ; } rtDW . myvb1smtw3 = 0U ; MdlInitialize ( ) ; } void
MdlOutputs ( int_T tid ) { real_T bajocvrwsf ; real_T bqgfst5ooz ; real_T
cgxl1dvajt ; real_T cxi2xbjqmg ; real_T fjotosmcdf_idx_2 ; real_T fyjrrlatnb
; real_T ieai22d0ud ; real_T k3oen2zzrt ; real_T kdziahxabj ; real_T
knythayab4 ; real_T kun2e3hthp ; real_T mqpramfs2p ; real_T ottbh1vhdu ; if (
ssIsSampleHit ( rtS , 2 , 0 ) ) { muDoubleScalarSinCos ( rtDW . pq0qc0q4qt ,
& kdziahxabj , & mqpramfs2p ) ; ottbh1vhdu = rtDW . eowmvoivfm ; ieai22d0ud =
rtDW . ooiulikieu ; rtB . doh1ukidqb = rtDW . eowmvoivfm * mqpramfs2p + rtDW
. ooiulikieu * kdziahxabj ; rtB . bnvxvacbbl = ( ( - rtDW . eowmvoivfm -
1.7320508075688772 * rtDW . ooiulikieu ) * mqpramfs2p + ( 1.7320508075688772
* rtDW . eowmvoivfm - rtDW . ooiulikieu ) * kdziahxabj ) * 0.5 ; { real_T
accum ; int_T * switch_status = ( int_T * ) rtDW . heo4xx0bdx . SWITCH_STATUS
; int_T * switch_status_init = ( int_T * ) rtDW . heo4xx0bdx .
SWITCH_STATUS_INIT ; int_T * SwitchChange = ( int_T * ) rtDW . heo4xx0bdx .
SW_CHG ; int_T * gState = ( int_T * ) rtDW . heo4xx0bdx . G_STATE ; real_T *
yswitch = ( real_T * ) rtDW . heo4xx0bdx . Y_SWITCH ; int_T * switchTypes = (
int_T * ) rtDW . heo4xx0bdx . SWITCH_TYPES ; int_T * idxOutSw = ( int_T * )
rtDW . heo4xx0bdx . IDX_OUT_SW ; real_T * DxCol = ( real_T * ) rtDW .
heo4xx0bdx . DX_COL ; real_T * tmp2 = ( real_T * ) rtDW . heo4xx0bdx . TMP2 ;
real_T * uswlast = ( real_T * ) rtDW . heo4xx0bdx . USWLAST ; int_T newState
; int_T swChanged = 0 ; int loopsToDo = 20 ; real_T temp ; memcpy (
switch_status_init , switch_status , 6 * sizeof ( int_T ) ) ; memcpy (
uswlast , & rtB . gumxvgfbxn [ 0 ] , 6 * sizeof ( real_T ) ) ; do { if (
loopsToDo == 1 ) { swChanged = 0 ; { int_T i1 ; for ( i1 = 0 ; i1 < 6 ; i1 ++
) { swChanged = ( ( SwitchChange [ i1 ] = switch_status_init [ i1 ] -
switch_status [ i1 ] ) != 0 ) ? 1 : swChanged ; switch_status [ i1 ] =
switch_status_init [ i1 ] ; } } } else { real_T * Ds = ( real_T * ) rtDW .
heo4xx0bdx . DS ; { int_T i1 ; real_T * y0 = & rtB . gumxvgfbxn [ 0 ] ; for (
i1 = 0 ; i1 < 8 ; i1 ++ ) { accum = 0.0 ; { int_T i2 ; const real_T * u0 = &
rtP . SwitchCurrents_Value [ 0 ] ; for ( i2 = 0 ; i2 < 6 ; i2 ++ ) { accum +=
* ( Ds ++ ) * u0 [ i2 ] ; } accum += * ( Ds ++ ) * rtB . doh1ukidqb ; accum
+= * ( Ds ++ ) * rtB . bnvxvacbbl ; accum += * ( Ds ++ ) * rtP .
DCVoltageSource_Amplitude ; } y0 [ i1 ] = accum ; } } swChanged = 0 ; { int_T
i1 ; real_T * y0 = & rtB . gumxvgfbxn [ 0 ] ; for ( i1 = 0 ; i1 < 6 ; i1 ++ )
{ newState = ( ( y0 [ i1 ] > 0.0 ) && ( gState [ i1 ] > 0 ) ) || ( y0 [ i1 ]
< 0.0 ) ? 1 : ( ( ( y0 [ i1 ] > 0.0 ) && gState [ i1 ] == 0 ) ? 0 :
switch_status [ i1 ] ) ; swChanged = ( ( SwitchChange [ i1 ] = newState -
switch_status [ i1 ] ) != 0 ) ? 1 : swChanged ; switch_status [ i1 ] =
newState ; } } } if ( swChanged ) { real_T * Ds = ( real_T * ) rtDW .
heo4xx0bdx . DS ; real_T a1 ; { int_T i1 ; for ( i1 = 0 ; i1 < 6 ; i1 ++ ) {
if ( SwitchChange [ i1 ] != 0 ) { a1 = 1000.0 * SwitchChange [ i1 ] ; temp =
1 / ( 1 - Ds [ i1 * 10 ] * a1 ) ; { int_T i2 ; for ( i2 = 0 ; i2 < 8 ; i2 ++
) { DxCol [ i2 ] = Ds [ i2 * 9 + i1 ] * temp * a1 ; } } DxCol [ i1 ] = temp ;
memcpy ( tmp2 , & Ds [ i1 * 9 ] , 9 * sizeof ( real_T ) ) ; memset ( & Ds [
i1 * 9 ] , '\0' , 9 * sizeof ( real_T ) ) ; { int_T i2 ; for ( i2 = 0 ; i2 <
8 ; i2 ++ ) { a1 = DxCol [ i2 ] ; { int_T i3 ; for ( i3 = 0 ; i3 < 9 ; i3 ++
) { Ds [ i2 * 9 + i3 ] += a1 * tmp2 [ i3 ] ; } } } } } } } } } while (
swChanged > 0 && -- loopsToDo > 0 ) ; if ( loopsToDo == 0 ) { real_T * Ds = (
real_T * ) rtDW . heo4xx0bdx . DS ; { int_T i1 ; real_T * y0 = & rtB .
gumxvgfbxn [ 0 ] ; for ( i1 = 0 ; i1 < 8 ; i1 ++ ) { accum = 0.0 ; { int_T i2
; const real_T * u0 = & rtP . SwitchCurrents_Value [ 0 ] ; for ( i2 = 0 ; i2
< 6 ; i2 ++ ) { accum += * ( Ds ++ ) * u0 [ i2 ] ; } accum += * ( Ds ++ ) *
rtB . doh1ukidqb ; accum += * ( Ds ++ ) * rtB . bnvxvacbbl ; accum += * ( Ds
++ ) * rtP . DCVoltageSource_Amplitude ; } y0 [ i1 ] = accum ; } } } { int_T
i1 ; real_T * y1 = & rtB . i24nyf40tk [ 0 ] ; for ( i1 = 0 ; i1 < 6 ; i1 ++ )
{ y1 [ i1 ] = ( real_T ) switch_status [ i1 ] ; } } } rtB . ck12s04b5q = (
0.0 - rtB . bnvxvacbbl ) - rtB . doh1ukidqb ; bqgfst5ooz = ( ( 2.0 * rtB .
doh1ukidqb - rtB . bnvxvacbbl ) - rtB . ck12s04b5q ) / 3.0 ; knythayab4 = (
rtB . bnvxvacbbl - rtB . ck12s04b5q ) * 1.7320508075688772 / 3.0 ; rtB .
fj3fao1c3u = ( rtDW . pq0qc0q4qt - 1.5707963267948966 ) / 4.0 ; fyjrrlatnb =
rtP . Gain1_Gain * rtB . fj3fao1c3u ; cxi2xbjqmg = rtP . Constant2_Value - (
bqgfst5ooz * muDoubleScalarCos ( fyjrrlatnb ) + knythayab4 *
muDoubleScalarSin ( fyjrrlatnb ) ) ; cgxl1dvajt = rtP . PIDController_P *
cxi2xbjqmg + rtDW . po5e0yb1lh ; k3oen2zzrt = rtDW . okrwv1hpip ; rtB .
hn3dccr3ro = rtP . Gain_Gain * rtDW . okrwv1hpip ; bajocvrwsf = rtP .
Constant_Value - rtB . hn3dccr3ro ; bqgfst5ooz = ( rtP . PIDController4_P *
bajocvrwsf + rtDW . fqew3rv1xn ) - ( - bqgfst5ooz * muDoubleScalarSin (
fyjrrlatnb ) + knythayab4 * muDoubleScalarCos ( fyjrrlatnb ) ) ; kun2e3hthp =
rtP . PIDController3_P * bqgfst5ooz + rtDW . e1ionbamw0 ; knythayab4 =
cgxl1dvajt * muDoubleScalarSin ( fyjrrlatnb ) + kun2e3hthp *
muDoubleScalarCos ( fyjrrlatnb ) ; fyjrrlatnb = cgxl1dvajt *
muDoubleScalarCos ( fyjrrlatnb ) - kun2e3hthp * muDoubleScalarSin (
fyjrrlatnb ) ; if ( knythayab4 > rtP . Switch_Threshold ) { fjotosmcdf_idx_2
= rtP . Constant3_Value_bejh11f5do ; } else { fjotosmcdf_idx_2 = rtP .
Constant4_Value ; } if ( ( 1.7320508075688772 * fyjrrlatnb - knythayab4 ) /
2.0 > rtP . Switch1_Threshold ) { kun2e3hthp = rtP .
Constant3_Value_bejh11f5do ; } else { kun2e3hthp = rtP . Constant4_Value ; }
if ( ( - 1.7320508075688772 * fyjrrlatnb - knythayab4 ) / 2.0 > rtP .
Switch2_Threshold ) { cgxl1dvajt = rtP . Constant3_Value_bejh11f5do ; } else
{ cgxl1dvajt = rtP . Constant4_Value ; } rtB . khzjqq4aca = ( 2.0 *
kun2e3hthp + fjotosmcdf_idx_2 ) + 4.0 * cgxl1dvajt ; rtB . of4xqa4iyq = ( -
1.7320508075688772 * fyjrrlatnb + knythayab4 ) * ( 1.7320508075688772 * rtP .
Constant_Value_ahnta5b1bi ) / ( 2.0 * rtP . Constant1_Value ) ; rtB .
gys1h2d20i = ( 1.7320508075688772 * fyjrrlatnb + knythayab4 ) * (
1.7320508075688772 * rtP . Constant_Value_ahnta5b1bi ) / ( 2.0 * rtP .
Constant1_Value ) ; fyjrrlatnb = rtP . Gain2_Gain * rtB . of4xqa4iyq ; rtB .
m0soobc2tx = 1.7320508075688772 * rtP . Constant_Value_ahnta5b1bi *
knythayab4 / rtP . Constant1_Value ; cgxl1dvajt = rtP . Gain_Gain_hehkc3jgen
* rtB . m0soobc2tx ; knythayab4 = rtP . Gain1_Gain_n3fx5vigfy * rtB .
gys1h2d20i ; switch ( ( int32_T ) rtB . khzjqq4aca ) { case 1 : kun2e3hthp =
rtB . of4xqa4iyq ; break ; case 2 : kun2e3hthp = rtB . gys1h2d20i ; break ;
case 3 : kun2e3hthp = fyjrrlatnb ; break ; case 4 : kun2e3hthp = cgxl1dvajt ;
break ; case 5 : kun2e3hthp = rtB . m0soobc2tx ; break ; default : kun2e3hthp
= knythayab4 ; break ; } switch ( ( int32_T ) rtB . khzjqq4aca ) { case 1 :
fyjrrlatnb = rtB . gys1h2d20i ; break ; case 2 : fyjrrlatnb = cgxl1dvajt ;
break ; case 3 : fyjrrlatnb = rtB . m0soobc2tx ; break ; case 4 : fyjrrlatnb
= rtB . of4xqa4iyq ; break ; case 5 : fyjrrlatnb = knythayab4 ; break ; } if
( ( rtP . Constant_Value_ahnta5b1bi - fyjrrlatnb ) - kun2e3hthp > rtP .
Switch_Threshold_d3pcfftxzn ) { fjotosmcdf_idx_2 = rtP .
Constant_Value_ahnta5b1bi ; } else { fyjrrlatnb = kun2e3hthp * rtP .
Constant_Value_ahnta5b1bi / ( kun2e3hthp + fyjrrlatnb ) ; kun2e3hthp =
fyjrrlatnb ; fjotosmcdf_idx_2 = fyjrrlatnb ; } cgxl1dvajt = ( ( kun2e3hthp +
fjotosmcdf_idx_2 ) - fyjrrlatnb ) / 4.0 ; knythayab4 = ( ( fjotosmcdf_idx_2 -
kun2e3hthp ) - fyjrrlatnb ) / 4.0 ; kun2e3hthp = ( ( kun2e3hthp +
fjotosmcdf_idx_2 ) + fyjrrlatnb ) / 4.0 ; switch ( ( int32_T ) rtB .
khzjqq4aca ) { case 1 : rtB . btnvqswzr5 = cgxl1dvajt ; break ; case 2 : rtB
. btnvqswzr5 = knythayab4 ; break ; case 3 : rtB . btnvqswzr5 = knythayab4 ;
break ; case 4 : rtB . btnvqswzr5 = kun2e3hthp ; break ; case 5 : rtB .
btnvqswzr5 = kun2e3hthp ; break ; default : rtB . btnvqswzr5 = cgxl1dvajt ;
break ; } } rtB . bm2pphhktx = look1_binlxpw ( muDoubleScalarRem ( ssGetT (
rtS ) , rtP . Constant_Value_gnz10l4nxj ) , rtP . LookUpTable1_bp01Data , rtP
. RepeatingSequence_rep_seq_y , 2U ) ; if ( ssIsSampleHit ( rtS , 2 , 0 ) ) {
switch ( ( int32_T ) rtB . khzjqq4aca ) { case 1 : rtB . ml1gl3cyt3 =
knythayab4 ; break ; case 2 : rtB . ml1gl3cyt3 = kun2e3hthp ; break ; case 3
: rtB . ml1gl3cyt3 = cgxl1dvajt ; break ; case 4 : rtB . ml1gl3cyt3 =
cgxl1dvajt ; break ; case 5 : rtB . ml1gl3cyt3 = knythayab4 ; break ; default
: rtB . ml1gl3cyt3 = kun2e3hthp ; break ; } } if ( ssIsSampleHit ( rtS , 1 ,
0 ) ) { if ( ssIsModeUpdateTimeStep ( rtS ) ) { rtDW . afmy0cnqxp = ( rtB .
bm2pphhktx >= rtB . btnvqswzr5 ) ; } rtB . o3ipjb4ia1 = rtDW . afmy0cnqxp ;
rtB . oehdg5tfvl = ! rtDW . afmy0cnqxp ; } if ( ssIsSampleHit ( rtS , 2 , 0 )
) { switch ( ( int32_T ) rtB . khzjqq4aca ) { case 1 : rtB . k344ayyian =
kun2e3hthp ; break ; case 2 : rtB . k344ayyian = cgxl1dvajt ; break ; case 3
: rtB . k344ayyian = kun2e3hthp ; break ; case 4 : rtB . k344ayyian =
knythayab4 ; break ; case 5 : rtB . k344ayyian = cgxl1dvajt ; break ; default
: rtB . k344ayyian = knythayab4 ; break ; } } if ( ssIsSampleHit ( rtS , 1 ,
0 ) ) { if ( ssIsModeUpdateTimeStep ( rtS ) ) { rtDW . jus0vqnxsi = ( rtB .
bm2pphhktx >= rtB . ml1gl3cyt3 ) ; } rtB . d4er4shvvt = rtDW . jus0vqnxsi ;
rtB . kuqyy4l1im = ! rtDW . jus0vqnxsi ; if ( ssIsModeUpdateTimeStep ( rtS )
) { rtDW . krwklz2yp0 = ( rtB . bm2pphhktx >= rtB . k344ayyian ) ; } rtB .
lbnbux40tm = rtDW . krwklz2yp0 ; rtB . a31fuchwx4 = ! rtDW . krwklz2yp0 ; if
( rtB . o3ipjb4ia1 > rtP . Saturation_UpperSat ) { fjotosmcdf_idx_2 = rtP .
Saturation_UpperSat ; } else if ( rtB . o3ipjb4ia1 < rtP .
Saturation_LowerSat ) { fjotosmcdf_idx_2 = rtP . Saturation_LowerSat ; } else
{ fjotosmcdf_idx_2 = rtB . o3ipjb4ia1 ; } rtB . fgm2ey422o [ 0 ] =
fjotosmcdf_idx_2 * rtB . ir01thxxfd ; if ( rtB . oehdg5tfvl > rtP .
Saturation_UpperSat ) { fjotosmcdf_idx_2 = rtP . Saturation_UpperSat ; } else
if ( rtB . oehdg5tfvl < rtP . Saturation_LowerSat ) { fjotosmcdf_idx_2 = rtP
. Saturation_LowerSat ; } else { fjotosmcdf_idx_2 = rtB . oehdg5tfvl ; } rtB
. fgm2ey422o [ 1 ] = fjotosmcdf_idx_2 * rtB . ir01thxxfd ; if ( rtB .
d4er4shvvt > rtP . Saturation_UpperSat ) { fjotosmcdf_idx_2 = rtP .
Saturation_UpperSat ; } else if ( rtB . d4er4shvvt < rtP .
Saturation_LowerSat ) { fjotosmcdf_idx_2 = rtP . Saturation_LowerSat ; } else
{ fjotosmcdf_idx_2 = rtB . d4er4shvvt ; } rtB . fgm2ey422o [ 2 ] =
fjotosmcdf_idx_2 * rtB . ir01thxxfd ; if ( rtB . kuqyy4l1im > rtP .
Saturation_UpperSat ) { fjotosmcdf_idx_2 = rtP . Saturation_UpperSat ; } else
if ( rtB . kuqyy4l1im < rtP . Saturation_LowerSat ) { fjotosmcdf_idx_2 = rtP
. Saturation_LowerSat ; } else { fjotosmcdf_idx_2 = rtB . kuqyy4l1im ; } rtB
. fgm2ey422o [ 3 ] = fjotosmcdf_idx_2 * rtB . ir01thxxfd ; if ( rtB .
lbnbux40tm > rtP . Saturation_UpperSat ) { fjotosmcdf_idx_2 = rtP .
Saturation_UpperSat ; } else if ( rtB . lbnbux40tm < rtP .
Saturation_LowerSat ) { fjotosmcdf_idx_2 = rtP . Saturation_LowerSat ; } else
{ fjotosmcdf_idx_2 = rtB . lbnbux40tm ; } rtB . fgm2ey422o [ 4 ] =
fjotosmcdf_idx_2 * rtB . ir01thxxfd ; if ( rtB . a31fuchwx4 > rtP .
Saturation_UpperSat ) { fjotosmcdf_idx_2 = rtP . Saturation_UpperSat ; } else
if ( rtB . a31fuchwx4 < rtP . Saturation_LowerSat ) { fjotosmcdf_idx_2 = rtP
. Saturation_LowerSat ; } else { fjotosmcdf_idx_2 = rtB . a31fuchwx4 ; } rtB
. fgm2ey422o [ 5 ] = fjotosmcdf_idx_2 * rtB . ir01thxxfd ; } if (
ssIsSampleHit ( rtS , 2 , 0 ) ) { rtB . p3qdmqq2jr = ( 0.0 * ottbh1vhdu *
ieai22d0ud + 0.1119 * ottbh1vhdu ) * 6.0 ; rtB . kblebvykwt = rtP .
PIDController_I * cxi2xbjqmg ; rtB . lhq4adqmd0 = rtP . PIDController3_I *
bqgfst5ooz ; rtB . nai45kmsg3 = rtP . PIDController4_I * bajocvrwsf ; rtB .
cis3ukuxpf = rtP . Gain_Gain_cnsevagfns * k3oen2zzrt ; rtB . mew0r2rmut = ( (
( 2.0 * rtB . gumxvgfbxn [ 6 ] + rtB . gumxvgfbxn [ 7 ] ) * kdziahxabj + -
1.7320508075688772 * rtB . gumxvgfbxn [ 7 ] * mqpramfs2p ) *
0.33333333333333331 * rtP . uLd_Gain - rtP . RLd_Gain * ieai22d0ud ) + rtB .
cis3ukuxpf * ottbh1vhdu * rtP . LqLd_Gain ; rtB . eynh445hv1 = ( ( ( ( 2.0 *
rtB . gumxvgfbxn [ 6 ] + rtB . gumxvgfbxn [ 7 ] ) * mqpramfs2p +
1.7320508075688772 * rtB . gumxvgfbxn [ 7 ] * kdziahxabj ) *
0.33333333333333331 * rtP . uLq_Gain - rtP . RLq_Gain * ottbh1vhdu ) -
ieai22d0ud * rtB . cis3ukuxpf * rtP . LdLq_Gain ) - rtP . lamLq_Gain * rtB .
cis3ukuxpf ; rtB . f0qbz1rzka = ( ( rtB . p3qdmqq2jr - rtP . Constant3_Value
) - ( rtP . CoulombViscousFriction_offset * muDoubleScalarSign ( k3oen2zzrt )
+ rtP . CoulombViscousFriction_gain * k3oen2zzrt ) ) * rtP .
Gain2_Gain_nink3v2kty ; } if ( ssIsSampleHit ( rtS , 1 , 0 ) ) { } if (
ssIsSampleHit ( rtS , 2 , 0 ) ) { } if ( ssIsSampleHit ( rtS , 1 , 0 ) ) { }
UNUSED_PARAMETER ( tid ) ; } void MdlOutputsTID3 ( int_T tid ) { rtB .
ir01thxxfd = ( rtP . CompareToConstant_const >= 0.0 ) ; UNUSED_PARAMETER (
tid ) ; } void MdlUpdate ( int_T tid ) { if ( ssIsSampleHit ( rtS , 2 , 0 ) )
{ rtDW . pq0qc0q4qt += rtP . DiscreteTimeIntegrator1_gainval * rtB .
cis3ukuxpf ; rtDW . eowmvoivfm += rtP . DiscreteTimeIntegrator_gainval * rtB
. eynh445hv1 ; rtDW . ooiulikieu += rtP .
DiscreteTimeIntegrator_gainval_ag5cij0zd5 * rtB . mew0r2rmut ; { int_T *
gState = ( int_T * ) rtDW . heo4xx0bdx . G_STATE ; { int_T i1 ; const real_T
* u1 = & rtB . fgm2ey422o [ 0 ] ; for ( i1 = 0 ; i1 < 6 ; i1 ++ ) { * (
gState ++ ) = ( int_T ) u1 [ i1 ] ; } } } rtDW . po5e0yb1lh += rtP .
Integrator_gainval * rtB . kblebvykwt ; rtDW . okrwv1hpip += rtP .
DiscreteTimeIntegrator_gainval_mjgsuxrz21 * rtB . f0qbz1rzka ; rtDW .
fqew3rv1xn += rtP . Integrator_gainval_ac2bwkmf4o * rtB . nai45kmsg3 ; rtDW .
e1ionbamw0 += rtP . Integrator_gainval_if4krzbtot * rtB . lhq4adqmd0 ; }
UNUSED_PARAMETER ( tid ) ; } void MdlUpdateTID3 ( int_T tid ) {
UNUSED_PARAMETER ( tid ) ; } void MdlZeroCrossings ( void ) { ZCV * _rtZCSV ;
_rtZCSV = ( ( ZCV * ) ssGetSolverZcSignalVector ( rtS ) ) ; _rtZCSV ->
b4eleawi4u = rtB . bm2pphhktx - rtB . btnvqswzr5 ; _rtZCSV -> c4vijg1mkn =
rtB . bm2pphhktx - rtB . ml1gl3cyt3 ; _rtZCSV -> jaejp04hra = rtB .
bm2pphhktx - rtB . k344ayyian ; } void MdlTerminate ( void ) { { free ( rtDW
. heo4xx0bdx . DS ) ; free ( rtDW . heo4xx0bdx . DX_COL ) ; free ( rtDW .
heo4xx0bdx . TMP2 ) ; free ( rtDW . heo4xx0bdx . G_STATE ) ; free ( rtDW .
heo4xx0bdx . SWITCH_STATUS ) ; free ( rtDW . heo4xx0bdx . SW_CHG ) ; free (
rtDW . heo4xx0bdx . SWITCH_STATUS_INIT ) ; } } static void
mr_foc1_cacheDataAsMxArray ( mxArray * destArray , mwIndex i , int j , const
void * srcData , size_t numBytes ) ; static void mr_foc1_cacheDataAsMxArray (
mxArray * destArray , mwIndex i , int j , const void * srcData , size_t
numBytes ) { mxArray * newArray = mxCreateUninitNumericMatrix ( ( size_t ) 1
, numBytes , mxUINT8_CLASS , mxREAL ) ; memcpy ( ( uint8_T * ) mxGetData (
newArray ) , ( const uint8_T * ) srcData , numBytes ) ; mxSetFieldByNumber (
destArray , i , j , newArray ) ; } static void mr_foc1_restoreDataFromMxArray
( void * destData , const mxArray * srcArray , mwIndex i , int j , size_t
numBytes ) ; static void mr_foc1_restoreDataFromMxArray ( void * destData ,
const mxArray * srcArray , mwIndex i , int j , size_t numBytes ) { memcpy ( (
uint8_T * ) destData , ( const uint8_T * ) mxGetData ( mxGetFieldByNumber (
srcArray , i , j ) ) , numBytes ) ; } static void
mr_foc1_cacheBitFieldToMxArray ( mxArray * destArray , mwIndex i , int j ,
uint_T bitVal ) ; static void mr_foc1_cacheBitFieldToMxArray ( mxArray *
destArray , mwIndex i , int j , uint_T bitVal ) { mxSetFieldByNumber (
destArray , i , j , mxCreateDoubleScalar ( ( real_T ) bitVal ) ) ; } static
uint_T mr_foc1_extractBitFieldFromMxArray ( const mxArray * srcArray ,
mwIndex i , int j , uint_T numBits ) ; static uint_T
mr_foc1_extractBitFieldFromMxArray ( const mxArray * srcArray , mwIndex i ,
int j , uint_T numBits ) { const uint_T varVal = ( uint_T ) mxGetScalar (
mxGetFieldByNumber ( srcArray , i , j ) ) ; return varVal & ( ( 1u << numBits
) - 1u ) ; } static void mr_foc1_cacheDataToMxArrayWithOffset ( mxArray *
destArray , mwIndex i , int j , mwIndex offset , const void * srcData ,
size_t numBytes ) ; static void mr_foc1_cacheDataToMxArrayWithOffset (
mxArray * destArray , mwIndex i , int j , mwIndex offset , const void *
srcData , size_t numBytes ) { uint8_T * varData = ( uint8_T * ) mxGetData (
mxGetFieldByNumber ( destArray , i , j ) ) ; memcpy ( ( uint8_T * ) & varData
[ offset * numBytes ] , ( const uint8_T * ) srcData , numBytes ) ; } static
void mr_foc1_restoreDataFromMxArrayWithOffset ( void * destData , const
mxArray * srcArray , mwIndex i , int j , mwIndex offset , size_t numBytes ) ;
static void mr_foc1_restoreDataFromMxArrayWithOffset ( void * destData ,
const mxArray * srcArray , mwIndex i , int j , mwIndex offset , size_t
numBytes ) { const uint8_T * varData = ( const uint8_T * ) mxGetData (
mxGetFieldByNumber ( srcArray , i , j ) ) ; memcpy ( ( uint8_T * ) destData ,
( const uint8_T * ) & varData [ offset * numBytes ] , numBytes ) ; } static
void mr_foc1_cacheBitFieldToCellArrayWithOffset ( mxArray * destArray ,
mwIndex i , int j , mwIndex offset , uint_T fieldVal ) ; static void
mr_foc1_cacheBitFieldToCellArrayWithOffset ( mxArray * destArray , mwIndex i
, int j , mwIndex offset , uint_T fieldVal ) { mxSetCell ( mxGetFieldByNumber
( destArray , i , j ) , offset , mxCreateDoubleScalar ( ( real_T ) fieldVal )
) ; } static uint_T mr_foc1_extractBitFieldFromCellArrayWithOffset ( const
mxArray * srcArray , mwIndex i , int j , mwIndex offset , uint_T numBits ) ;
static uint_T mr_foc1_extractBitFieldFromCellArrayWithOffset ( const mxArray
* srcArray , mwIndex i , int j , mwIndex offset , uint_T numBits ) { const
uint_T fieldVal = ( uint_T ) mxGetScalar ( mxGetCell ( mxGetFieldByNumber (
srcArray , i , j ) , offset ) ) ; return fieldVal & ( ( 1u << numBits ) - 1u
) ; } mxArray * mr_foc1_GetDWork ( ) { static const char_T * ssDWFieldNames [
3 ] = { "rtB" , "rtDW" , "NULL_PrevZCX" , } ; mxArray * ssDW =
mxCreateStructMatrix ( 1 , 1 , 3 , ssDWFieldNames ) ;
mr_foc1_cacheDataAsMxArray ( ssDW , 0 , 0 , ( const void * ) & ( rtB ) ,
sizeof ( rtB ) ) ; { static const char_T * rtdwDataFieldNames [ 15 ] = {
"rtDW.pq0qc0q4qt" , "rtDW.eowmvoivfm" , "rtDW.ooiulikieu" , "rtDW.po5e0yb1lh"
, "rtDW.okrwv1hpip" , "rtDW.fqew3rv1xn" , "rtDW.e1ionbamw0" ,
"rtDW.jy5c5fihyg" , "rtDW.k0ry3y4g00" , "rtDW.igdieiwmgk" , "rtDW.ptj1w5chqw"
, "rtDW.myvb1smtw3" , "rtDW.afmy0cnqxp" , "rtDW.jus0vqnxsi" ,
"rtDW.krwklz2yp0" , } ; mxArray * rtdwData = mxCreateStructMatrix ( 1 , 1 ,
15 , rtdwDataFieldNames ) ; mr_foc1_cacheDataAsMxArray ( rtdwData , 0 , 0 , (
const void * ) & ( rtDW . pq0qc0q4qt ) , sizeof ( rtDW . pq0qc0q4qt ) ) ;
mr_foc1_cacheDataAsMxArray ( rtdwData , 0 , 1 , ( const void * ) & ( rtDW .
eowmvoivfm ) , sizeof ( rtDW . eowmvoivfm ) ) ; mr_foc1_cacheDataAsMxArray (
rtdwData , 0 , 2 , ( const void * ) & ( rtDW . ooiulikieu ) , sizeof ( rtDW .
ooiulikieu ) ) ; mr_foc1_cacheDataAsMxArray ( rtdwData , 0 , 3 , ( const void
* ) & ( rtDW . po5e0yb1lh ) , sizeof ( rtDW . po5e0yb1lh ) ) ;
mr_foc1_cacheDataAsMxArray ( rtdwData , 0 , 4 , ( const void * ) & ( rtDW .
okrwv1hpip ) , sizeof ( rtDW . okrwv1hpip ) ) ; mr_foc1_cacheDataAsMxArray (
rtdwData , 0 , 5 , ( const void * ) & ( rtDW . fqew3rv1xn ) , sizeof ( rtDW .
fqew3rv1xn ) ) ; mr_foc1_cacheDataAsMxArray ( rtdwData , 0 , 6 , ( const void
* ) & ( rtDW . e1ionbamw0 ) , sizeof ( rtDW . e1ionbamw0 ) ) ;
mr_foc1_cacheDataAsMxArray ( rtdwData , 0 , 7 , ( const void * ) & ( rtDW .
jy5c5fihyg ) , sizeof ( rtDW . jy5c5fihyg ) ) ; mr_foc1_cacheDataAsMxArray (
rtdwData , 0 , 8 , ( const void * ) & ( rtDW . k0ry3y4g00 ) , sizeof ( rtDW .
k0ry3y4g00 ) ) ; mr_foc1_cacheDataAsMxArray ( rtdwData , 0 , 9 , ( const void
* ) & ( rtDW . igdieiwmgk ) , sizeof ( rtDW . igdieiwmgk ) ) ;
mr_foc1_cacheDataAsMxArray ( rtdwData , 0 , 10 , ( const void * ) & ( rtDW .
ptj1w5chqw ) , sizeof ( rtDW . ptj1w5chqw ) ) ; mr_foc1_cacheDataAsMxArray (
rtdwData , 0 , 11 , ( const void * ) & ( rtDW . myvb1smtw3 ) , sizeof ( rtDW
. myvb1smtw3 ) ) ; mr_foc1_cacheDataAsMxArray ( rtdwData , 0 , 12 , ( const
void * ) & ( rtDW . afmy0cnqxp ) , sizeof ( rtDW . afmy0cnqxp ) ) ;
mr_foc1_cacheDataAsMxArray ( rtdwData , 0 , 13 , ( const void * ) & ( rtDW .
jus0vqnxsi ) , sizeof ( rtDW . jus0vqnxsi ) ) ; mr_foc1_cacheDataAsMxArray (
rtdwData , 0 , 14 , ( const void * ) & ( rtDW . krwklz2yp0 ) , sizeof ( rtDW
. krwklz2yp0 ) ) ; mxSetFieldByNumber ( ssDW , 0 , 1 , rtdwData ) ; } return
ssDW ; } void mr_foc1_SetDWork ( const mxArray * ssDW ) { ( void ) ssDW ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtB ) , ssDW , 0 , 0 , sizeof
( rtB ) ) ; { const mxArray * rtdwData = mxGetFieldByNumber ( ssDW , 0 , 1 )
; mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . pq0qc0q4qt ) ,
rtdwData , 0 , 0 , sizeof ( rtDW . pq0qc0q4qt ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . eowmvoivfm ) ,
rtdwData , 0 , 1 , sizeof ( rtDW . eowmvoivfm ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . ooiulikieu ) ,
rtdwData , 0 , 2 , sizeof ( rtDW . ooiulikieu ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . po5e0yb1lh ) ,
rtdwData , 0 , 3 , sizeof ( rtDW . po5e0yb1lh ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . okrwv1hpip ) ,
rtdwData , 0 , 4 , sizeof ( rtDW . okrwv1hpip ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . fqew3rv1xn ) ,
rtdwData , 0 , 5 , sizeof ( rtDW . fqew3rv1xn ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . e1ionbamw0 ) ,
rtdwData , 0 , 6 , sizeof ( rtDW . e1ionbamw0 ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . jy5c5fihyg ) ,
rtdwData , 0 , 7 , sizeof ( rtDW . jy5c5fihyg ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . k0ry3y4g00 ) ,
rtdwData , 0 , 8 , sizeof ( rtDW . k0ry3y4g00 ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . igdieiwmgk ) ,
rtdwData , 0 , 9 , sizeof ( rtDW . igdieiwmgk ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . ptj1w5chqw ) ,
rtdwData , 0 , 10 , sizeof ( rtDW . ptj1w5chqw ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . myvb1smtw3 ) ,
rtdwData , 0 , 11 , sizeof ( rtDW . myvb1smtw3 ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . afmy0cnqxp ) ,
rtdwData , 0 , 12 , sizeof ( rtDW . afmy0cnqxp ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . jus0vqnxsi ) ,
rtdwData , 0 , 13 , sizeof ( rtDW . jus0vqnxsi ) ) ;
mr_foc1_restoreDataFromMxArray ( ( void * ) & ( rtDW . krwklz2yp0 ) ,
rtdwData , 0 , 14 , sizeof ( rtDW . krwklz2yp0 ) ) ; } } mxArray *
mr_foc1_GetSimStateDisallowedBlocks ( ) { mxArray * data = mxCreateCellMatrix
( 10 , 3 ) ; mwIndex subs [ 2 ] , offset ; { static const char_T * blockType
[ 10 ] = { "S-Function" , "Scope" , "Scope" , "Scope" , "Scope" , "Scope" ,
"Scope" , "Scope" , "Scope" , "Scope" , } ; static const char_T * blockPath [
10 ] = { "foc1/powergui/EquivalentModel1/State-Space" , "foc1/machine_angle"
, "foc1/&#x5B9A;&#x5B50;&#x7535;&#x6D41;" ,
"foc1/&#x7535;&#x78C1;&#x8F6C;&#x77E9;" , "foc1/&#x8F6C;&#x901F;" ,
"foc1/SVPWM /N" , "foc1/SVPWM /PWM " , "foc1/SVPWM /Scope" ,
"foc1/SVPWM /Subsystem1/Scope" , "foc1/SVPWM /Subsystem1/Scope1" , } ; static
const int reason [ 10 ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , } ; for (
subs [ 0 ] = 0 ; subs [ 0 ] < 10 ; ++ ( subs [ 0 ] ) ) { subs [ 1 ] = 0 ;
offset = mxCalcSingleSubscript ( data , 2 , subs ) ; mxSetCell ( data ,
offset , mxCreateString ( blockType [ subs [ 0 ] ] ) ) ; subs [ 1 ] = 1 ;
offset = mxCalcSingleSubscript ( data , 2 , subs ) ; mxSetCell ( data ,
offset , mxCreateString ( blockPath [ subs [ 0 ] ] ) ) ; subs [ 1 ] = 2 ;
offset = mxCalcSingleSubscript ( data , 2 , subs ) ; mxSetCell ( data ,
offset , mxCreateDoubleScalar ( ( real_T ) reason [ subs [ 0 ] ] ) ) ; } }
return data ; } void MdlInitializeSizes ( void ) { ssSetNumContStates ( rtS ,
0 ) ; ssSetNumY ( rtS , 0 ) ; ssSetNumU ( rtS , 0 ) ; ssSetDirectFeedThrough
( rtS , 0 ) ; ssSetNumSampleTimes ( rtS , 3 ) ; ssSetNumBlocks ( rtS , 160 )
; ssSetNumBlockIO ( rtS , 31 ) ; ssSetNumBlockParams ( rtS , 137 ) ; } void
MdlInitializeSampleTimes ( void ) { ssSetSampleTime ( rtS , 0 , 0.0 ) ;
ssSetSampleTime ( rtS , 1 , 0.0 ) ; ssSetSampleTime ( rtS , 2 , 1.0E-6 ) ;
ssSetOffsetTime ( rtS , 0 , 0.0 ) ; ssSetOffsetTime ( rtS , 1 , 1.0 ) ;
ssSetOffsetTime ( rtS , 2 , 0.0 ) ; } void raccel_set_checksum ( ) {
ssSetChecksumVal ( rtS , 0 , 4252159461U ) ; ssSetChecksumVal ( rtS , 1 ,
500321272U ) ; ssSetChecksumVal ( rtS , 2 , 3214158740U ) ; ssSetChecksumVal
( rtS , 3 , 463824658U ) ; }
#if defined(_MSC_VER)
#pragma optimize( "", off )
#endif
SimStruct * raccel_register_model ( ssExecutionInfo * executionInfo ) {
static struct _ssMdlInfo mdlInfo ; static struct _ssBlkInfo2 blkInfo2 ;
static struct _ssBlkInfoSLSize blkInfoSLSize ; ( void ) memset ( ( char_T * )
rtS , 0 , sizeof ( SimStruct ) ) ; ( void ) memset ( ( char_T * ) & mdlInfo ,
0 , sizeof ( struct _ssMdlInfo ) ) ; ( void ) memset ( ( char_T * ) &
blkInfo2 , 0 , sizeof ( struct _ssBlkInfo2 ) ) ; ( void ) memset ( ( char_T *
) & blkInfoSLSize , 0 , sizeof ( struct _ssBlkInfoSLSize ) ) ;
ssSetBlkInfo2Ptr ( rtS , & blkInfo2 ) ; ssSetBlkInfoSLSizePtr ( rtS , &
blkInfoSLSize ) ; ssSetMdlInfoPtr ( rtS , & mdlInfo ) ; ssSetExecutionInfo (
rtS , executionInfo ) ; slsaAllocOPModelData ( rtS ) ; { static time_T
mdlPeriod [ NSAMPLE_TIMES ] ; static time_T mdlOffset [ NSAMPLE_TIMES ] ;
static time_T mdlTaskTimes [ NSAMPLE_TIMES ] ; static int_T mdlTsMap [
NSAMPLE_TIMES ] ; static int_T mdlSampleHits [ NSAMPLE_TIMES ] ; static
boolean_T mdlTNextWasAdjustedPtr [ NSAMPLE_TIMES ] ; static int_T
mdlPerTaskSampleHits [ NSAMPLE_TIMES * NSAMPLE_TIMES ] ; static time_T
mdlTimeOfNextSampleHit [ NSAMPLE_TIMES ] ; { int_T i ; for ( i = 0 ; i <
NSAMPLE_TIMES ; i ++ ) { mdlPeriod [ i ] = 0.0 ; mdlOffset [ i ] = 0.0 ;
mdlTaskTimes [ i ] = 0.0 ; mdlTsMap [ i ] = i ; mdlSampleHits [ i ] = 1 ; } }
ssSetSampleTimePtr ( rtS , & mdlPeriod [ 0 ] ) ; ssSetOffsetTimePtr ( rtS , &
mdlOffset [ 0 ] ) ; ssSetSampleTimeTaskIDPtr ( rtS , & mdlTsMap [ 0 ] ) ;
ssSetTPtr ( rtS , & mdlTaskTimes [ 0 ] ) ; ssSetSampleHitPtr ( rtS , &
mdlSampleHits [ 0 ] ) ; ssSetTNextWasAdjustedPtr ( rtS , &
mdlTNextWasAdjustedPtr [ 0 ] ) ; ssSetPerTaskSampleHitsPtr ( rtS , &
mdlPerTaskSampleHits [ 0 ] ) ; ssSetTimeOfNextSampleHitPtr ( rtS , &
mdlTimeOfNextSampleHit [ 0 ] ) ; } ssSetSolverMode ( rtS ,
SOLVER_MODE_SINGLETASKING ) ; { ssSetBlockIO ( rtS , ( ( void * ) & rtB ) ) ;
( void ) memset ( ( ( void * ) & rtB ) , 0 , sizeof ( B ) ) ; } { void *
dwork = ( void * ) & rtDW ; ssSetRootDWork ( rtS , dwork ) ; ( void ) memset
( dwork , 0 , sizeof ( DW ) ) ; } { static DataTypeTransInfo dtInfo ; ( void
) memset ( ( char_T * ) & dtInfo , 0 , sizeof ( dtInfo ) ) ;
ssSetModelMappingInfo ( rtS , & dtInfo ) ; dtInfo . numDataTypes = 24 ;
dtInfo . dataTypeSizes = & rtDataTypeSizes [ 0 ] ; dtInfo . dataTypeNames = &
rtDataTypeNames [ 0 ] ; dtInfo . BTransTable = & rtBTransTable ; dtInfo .
PTransTable = & rtPTransTable ; dtInfo . dataTypeInfoTable =
rtDataTypeInfoTable ; } foc1_InitializeDataMapInfo ( ) ;
ssSetIsRapidAcceleratorActive ( rtS , true ) ; ssSetRootSS ( rtS , rtS ) ;
ssSetVersion ( rtS , SIMSTRUCT_VERSION_LEVEL2 ) ; ssSetModelName ( rtS ,
"foc1" ) ; ssSetPath ( rtS , "foc1" ) ; ssSetTStart ( rtS , 0.0 ) ;
ssSetTFinal ( rtS , 0.5 ) ; { static RTWLogInfo rt_DataLoggingInfo ;
rt_DataLoggingInfo . loggingInterval = ( NULL ) ; ssSetRTWLogInfo ( rtS , &
rt_DataLoggingInfo ) ; } { { static int_T rt_LoggedStateWidths [ ] = { 1 , 1
, 1 , 1 , 1 , 1 , 1 } ; static int_T rt_LoggedStateNumDimensions [ ] = { 1 ,
1 , 1 , 1 , 1 , 1 , 1 } ; static int_T rt_LoggedStateDimensions [ ] = { 1 , 1
, 1 , 1 , 1 , 1 , 1 } ; static boolean_T rt_LoggedStateIsVarDims [ ] = { 0 ,
0 , 0 , 0 , 0 , 0 , 0 } ; static BuiltInDTypeId rt_LoggedStateDataTypeIds [ ]
= { SS_DOUBLE , SS_DOUBLE , SS_DOUBLE , SS_DOUBLE , SS_DOUBLE , SS_DOUBLE ,
SS_DOUBLE } ; static int_T rt_LoggedStateComplexSignals [ ] = { 0 , 0 , 0 , 0
, 0 , 0 , 0 } ; static RTWPreprocessingFcnPtr
rt_LoggingStatePreprocessingFcnPtrs [ ] = { ( NULL ) , ( NULL ) , ( NULL ) ,
( NULL ) , ( NULL ) , ( NULL ) , ( NULL ) } ; static const char_T *
rt_LoggedStateLabels [ ] = { "DSTATE" , "DSTATE" , "DSTATE" , "DSTATE" ,
"DSTATE" , "DSTATE" , "DSTATE" } ; static const char_T *
rt_LoggedStateBlockNames [ ] = {
 "foc1/Permanent Magnet\nSynchronous Machine/Mechanical model/Discrete-Time\nIntegrator1"
,
 "foc1/Permanent Magnet\nSynchronous Machine/Electrical model/iq,id/iq/Discrete-Time\nIntegrator"
,
 "foc1/Permanent Magnet\nSynchronous Machine/Electrical model/iq,id/id/Discrete-Time\nIntegrator"
, "foc1/PID Controller/Integrator/Discrete/Integrator" ,
 "foc1/Permanent Magnet\nSynchronous Machine/Mechanical model/Discrete-Time\nIntegrator"
, "foc1/PID Controller4/Integrator/Discrete/Integrator" ,
"foc1/PID Controller3/Integrator/Discrete/Integrator" } ; static const char_T
* rt_LoggedStateNames [ ] = { "DSTATE" , "DSTATE" , "DSTATE" , "DSTATE" ,
"DSTATE" , "DSTATE" , "DSTATE" } ; static boolean_T rt_LoggedStateCrossMdlRef
[ ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; static RTWLogDataTypeConvert
rt_RTWLogDataTypeConvert [ ] = { { 0 , SS_DOUBLE , SS_DOUBLE , 0 , 0 , 0 ,
1.0 , 0 , 0.0 } , { 0 , SS_DOUBLE , SS_DOUBLE , 0 , 0 , 0 , 1.0 , 0 , 0.0 } ,
{ 0 , SS_DOUBLE , SS_DOUBLE , 0 , 0 , 0 , 1.0 , 0 , 0.0 } , { 0 , SS_DOUBLE ,
SS_DOUBLE , 0 , 0 , 0 , 1.0 , 0 , 0.0 } , { 0 , SS_DOUBLE , SS_DOUBLE , 0 , 0
, 0 , 1.0 , 0 , 0.0 } , { 0 , SS_DOUBLE , SS_DOUBLE , 0 , 0 , 0 , 1.0 , 0 ,
0.0 } , { 0 , SS_DOUBLE , SS_DOUBLE , 0 , 0 , 0 , 1.0 , 0 , 0.0 } } ; static
int_T rt_LoggedStateIdxList [ ] = { 0 , 1 , 2 , 3 , 4 , 5 , 6 } ; static
RTWLogSignalInfo rt_LoggedStateSignalInfo = { 7 , rt_LoggedStateWidths ,
rt_LoggedStateNumDimensions , rt_LoggedStateDimensions ,
rt_LoggedStateIsVarDims , ( NULL ) , ( NULL ) , rt_LoggedStateDataTypeIds ,
rt_LoggedStateComplexSignals , ( NULL ) , rt_LoggingStatePreprocessingFcnPtrs
, { rt_LoggedStateLabels } , ( NULL ) , ( NULL ) , ( NULL ) , {
rt_LoggedStateBlockNames } , { rt_LoggedStateNames } ,
rt_LoggedStateCrossMdlRef , rt_RTWLogDataTypeConvert , rt_LoggedStateIdxList
} ; static void * rt_LoggedStateSignalPtrs [ 7 ] ; rtliSetLogXSignalPtrs (
ssGetRTWLogInfo ( rtS ) , ( LogSignalPtrsType ) rt_LoggedStateSignalPtrs ) ;
rtliSetLogXSignalInfo ( ssGetRTWLogInfo ( rtS ) , & rt_LoggedStateSignalInfo
) ; rt_LoggedStateSignalPtrs [ 0 ] = ( void * ) & rtDW . pq0qc0q4qt ;
rt_LoggedStateSignalPtrs [ 1 ] = ( void * ) & rtDW . eowmvoivfm ;
rt_LoggedStateSignalPtrs [ 2 ] = ( void * ) & rtDW . ooiulikieu ;
rt_LoggedStateSignalPtrs [ 3 ] = ( void * ) & rtDW . po5e0yb1lh ;
rt_LoggedStateSignalPtrs [ 4 ] = ( void * ) & rtDW . okrwv1hpip ;
rt_LoggedStateSignalPtrs [ 5 ] = ( void * ) & rtDW . fqew3rv1xn ;
rt_LoggedStateSignalPtrs [ 6 ] = ( void * ) & rtDW . e1ionbamw0 ; }
rtliSetLogT ( ssGetRTWLogInfo ( rtS ) , "tout" ) ; rtliSetLogX (
ssGetRTWLogInfo ( rtS ) , "" ) ; rtliSetLogXFinal ( ssGetRTWLogInfo ( rtS ) ,
"xFinal" ) ; rtliSetLogVarNameModifier ( ssGetRTWLogInfo ( rtS ) , "none" ) ;
rtliSetLogFormat ( ssGetRTWLogInfo ( rtS ) , 4 ) ; rtliSetLogMaxRows (
ssGetRTWLogInfo ( rtS ) , 0 ) ; rtliSetLogDecimation ( ssGetRTWLogInfo ( rtS
) , 1 ) ; rtliSetLogY ( ssGetRTWLogInfo ( rtS ) , "" ) ;
rtliSetLogYSignalInfo ( ssGetRTWLogInfo ( rtS ) , ( NULL ) ) ;
rtliSetLogYSignalPtrs ( ssGetRTWLogInfo ( rtS ) , ( NULL ) ) ; } { static
ssSolverInfo slvrInfo ; static uint8_T zcAttributes [ 3 ] = { ( ZC_EVENT_ALL
) , ( ZC_EVENT_ALL ) , ( ZC_EVENT_ALL ) } ; ssSetStepSize ( rtS , 1.0E-6 ) ;
ssSetMinStepSize ( rtS , 0.0 ) ; ssSetMaxNumMinSteps ( rtS , - 1 ) ;
ssSetMinStepViolatedError ( rtS , 0 ) ; ssSetMaxStepSize ( rtS , 1.0E-6 ) ;
ssSetSolverMaxOrder ( rtS , - 1 ) ; ssSetSolverRefineFactor ( rtS , 1 ) ;
ssSetOutputTimes ( rtS , ( NULL ) ) ; ssSetNumOutputTimes ( rtS , 0 ) ;
ssSetOutputTimesOnly ( rtS , 0 ) ; ssSetOutputTimesIndex ( rtS , 0 ) ;
ssSetZCCacheNeedsReset ( rtS , 1 ) ; ssSetDerivCacheNeedsReset ( rtS , 0 ) ;
ssSetNumNonContDerivSigInfos ( rtS , 0 ) ; ssSetNonContDerivSigInfos ( rtS ,
( NULL ) ) ; ssSetSolverInfo ( rtS , & slvrInfo ) ; ssSetSolverName ( rtS ,
"VariableStepDiscrete" ) ; ssSetVariableStepSolver ( rtS , 1 ) ;
ssSetSolverConsistencyChecking ( rtS , 0 ) ; ssSetSolverAdaptiveZcDetection (
rtS , 0 ) ; ssSetSolverRobustResetMethod ( rtS , 0 ) ;
ssSetSolverStateProjection ( rtS , 0 ) ; ssSetSolverMassMatrixType ( rtS , (
ssMatrixType ) 0 ) ; ssSetSolverMassMatrixNzMax ( rtS , 0 ) ;
ssSetModelOutputs ( rtS , MdlOutputs ) ; ssSetModelUpdate ( rtS , MdlUpdate )
; ssSetSolverZcSignalAttrib ( rtS , zcAttributes ) ; ssSetSolverNumZcSignals
( rtS , 3 ) ; ssSetModelZeroCrossings ( rtS , MdlZeroCrossings ) ;
ssSetSolverConsecutiveZCsStepRelTol ( rtS , 2.8421709430404007E-13 ) ;
ssSetSolverMaxConsecutiveZCs ( rtS , 1000 ) ; ssSetSolverConsecutiveZCsError
( rtS , 2 ) ; ssSetSolverMaskedZcDiagnostic ( rtS , 1 ) ;
ssSetSolverIgnoredZcDiagnostic ( rtS , 1 ) ; ssSetTNextTid ( rtS , INT_MIN )
; ssSetTNext ( rtS , rtMinusInf ) ; ssSetSolverNeedsReset ( rtS ) ;
ssSetNumNonsampledZCs ( rtS , 3 ) ; } ssSetChecksumVal ( rtS , 0 ,
4252159461U ) ; ssSetChecksumVal ( rtS , 1 , 500321272U ) ; ssSetChecksumVal
( rtS , 2 , 3214158740U ) ; ssSetChecksumVal ( rtS , 3 , 463824658U ) ; {
static const sysRanDType rtAlwaysEnabled = SUBSYS_RAN_BC_ENABLE ; static
RTWExtModeInfo rt_ExtModeInfo ; static const sysRanDType * systemRan [ 3 ] ;
gblRTWExtModeInfo = & rt_ExtModeInfo ; ssSetRTWExtModeInfo ( rtS , &
rt_ExtModeInfo ) ; rteiSetSubSystemActiveVectorAddresses ( & rt_ExtModeInfo ,
systemRan ) ; systemRan [ 0 ] = & rtAlwaysEnabled ; systemRan [ 1 ] = &
rtAlwaysEnabled ; systemRan [ 2 ] = & rtAlwaysEnabled ;
rteiSetModelMappingInfoPtr ( ssGetRTWExtModeInfo ( rtS ) , &
ssGetModelMappingInfo ( rtS ) ) ; rteiSetChecksumsPtr ( ssGetRTWExtModeInfo (
rtS ) , ssGetChecksums ( rtS ) ) ; rteiSetTPtr ( ssGetRTWExtModeInfo ( rtS )
, ssGetTPtr ( rtS ) ) ; } slsaDisallowedBlocksForSimTargetOP ( rtS ,
mr_foc1_GetSimStateDisallowedBlocks ) ; slsaGetWorkFcnForSimTargetOP ( rtS ,
mr_foc1_GetDWork ) ; slsaSetWorkFcnForSimTargetOP ( rtS , mr_foc1_SetDWork )
; rt_RapidReadMatFileAndUpdateParams ( rtS ) ; if ( ssGetErrorStatus ( rtS )
) { return rtS ; } return rtS ; }
#if defined(_MSC_VER)
#pragma optimize( "", on )
#endif
const int_T gblParameterTuningTid = 3 ; void MdlOutputsParameterSampleTime (
int_T tid ) { MdlOutputsTID3 ( tid ) ; }
